import type { LLMModel } from '@/types/llmModels'
import { http, HttpResponse } from 'msw'

// 模拟数据
const models: LLMModel[] = [
  {
    id: 'gpt-4',
    name: 'gpt-4',
    title: 'GPT-4',
    alias: 'GPT-4',
    desc: 'OpenAI最强大的语言模型，擅长各种复杂任务',
    logo: 'https://openai.com/favicon.ico',
    vendor: 'OpenAI',
    releaseDate: '2023-03-14',
    version: '1.0',
    maxInputTokens: 8192,
    maxOutputTokens: 4096,
    capabilities: ['自然语言理解', '代码生成', '多语言翻译'],
    level: 2,
    params: {
      temperature: {
        name: '温度',
        desc: '控制输出的随机性',
        type: 'number',
        default: 0.7,
        min: 0,
        max: 1,
        step: 0.1
      },
      max_tokens: {
        name: '最大输出token数',
        desc: '控制生成文本的最大长度',
        type: 'number',
        default: 1024,
        min: 1,
        max: 1024,
        step: 1
      },
      top_p: {
        name: 'Top P',
        desc: '控制输出的多样性',
        type: 'number',
        default: 1,
        min: 0,
        max: 1,
        step: 0.1
      },
      top_k: {
        name: 'Top K',
        desc: '控制输出的多样性',
        type: 'number',
        default: 5,
        min: 1,
        max: 10,
        step: 1
      },
      frequency_penalty: {
        name: '频率惩罚',
        desc: '降低重复词语的出现概率',
        type: 'number',
        default: 0,
        min: -2,
        max: 2,
        step: 0.1
      },
      presence_penalty: {
        name: '存在惩罚',
        desc: '增加新主题出现的概率',
        type: 'number',
        default: 0,
        min: -2,
        max: 2,
        step: 0.1
      },
      repetition_penalty: {
        name: '重复惩罚',
        desc: '降低重复词语的出现概率',
        type: 'number',
        default: 1,
        min: 0.1,
        max: 1.5,
        step: 0.1
      }
    },
    pricing: {
      inputPrice: 0.03,
      outputPrice: 0.06,
      currency: 'USD'
    },
    apiEndpoint: 'https://api.openai.com/v1/chat/completions',
    documentationUrl: 'https://platform.openai.com/docs/models/gpt-4'
  },
  {
    id: 'gpt-3.5-turbo',
    name: 'gpt-3.5-turbo',
    title: 'GPT-3.5 Turbo',
    alias: 'ChatGPT',
    desc: 'OpenAI的高效语言模型，适用于大多数日常任务',
    logo: 'https://openai.com/favicon.ico',
    vendor: 'OpenAI',
    releaseDate: '2022-11-30',
    version: '1.0',
    maxInputTokens: 4096,
    maxOutputTokens: 4096,
    capabilities: ['对话生成', '文本摘要', '问答系统'],
    level: 1,
    params: {
      temperature: {
        name: '温度',
        desc: '控制输出的随机性',
        type: 'number',
        default: 0.7,
        min: 0,
        max: 1,
        step: 0.1
      },
      max_tokens: {
        name: '最大输出token数',
        desc: '控制生成文本的最大长度',
        type: 'number',
        default: 1024,
        min: 1,
        max: 1024,
        step: 1
      },
      top_p: {
        name: 'Top P',
        desc: '控制输出的多样性',
        type: 'number',
        default: 1,
        min: 0,
        max: 1,
        step: 0.1
      },
      top_k: {
        name: 'Top K',
        desc: '控制输出的多样性',
        type: 'number',
        default: 5,
        min: 1,
        max: 10,
        step: 1
      },
      frequency_penalty: {
        name: '频率惩罚',
        desc: '降低重复词语的出现概率',
        type: 'number',
        default: 0,
        min: -2,
        max: 2,
        step: 0.1
      },
      presence_penalty: {
        name: '存在惩罚',
        desc: '增加新主题出现的概率',
        type: 'number',
        default: 0,
        min: -2,
        max: 2,
        step: 0.1
      },
      repetition_penalty: {
        name: '重复惩罚',
        desc: '降低重复词语的出现概率',
        type: 'number',
        default: 1,
        min: 0.1,
        max: 1.5,
        step: 0.1
      }
    },
    pricing: {
      inputPrice: 0.0015,
      outputPrice: 0.002,
      currency: 'USD'
    },
    apiEndpoint: 'https://api.openai.com/v1/chat/completions',
    documentationUrl: 'https://platform.openai.com/docs/models/gpt-3-5'
  },
  {
    id: 'claude-2',
    name: 'claude-2',
    title: 'Claude 2',
    alias: 'Claude 2',
    desc: 'Anthropic的先进AI助手，擅长分析和创作',
    logo: 'https://www.anthropic.com/favicon.ico',
    vendor: 'Anthropic',
    releaseDate: '2023-07-11',
    version: '2.0',
    maxInputTokens: 100000,
    maxOutputTokens: 100000,
    capabilities: ['长文本处理', '代码分析', '创意写作'],
    level: 2,
    params: {
      temperature: {
        name: '温度',
        desc: '控制输出的随机性',
        type: 'number',
        default: 0.7,
        min: 0,
        max: 1,
        step: 0.1
      },
      max_tokens: {
        name: '最大输出token数',
        desc: '控制生成文本的最大长度',
        type: 'number',
        default: 1024,
        min: 1,
        max: 1024,
        step: 1
      },
      top_p: {
        name: 'Top P',
        desc: '控制输出的多样性',
        type: 'number',
        default: 1,
        min: 0,
        max: 1,
        step: 0.1
      },
      top_k: {
        name: 'Top K',
        desc: '控制输出的多样性',
        type: 'number',
        default: 5,
        min: 1,
        max: 10,
        step: 1
      },
      frequency_penalty: {
        name: '频率惩罚',
        desc: '降低重复词语的出现概率',
        type: 'number',
        default: 0,
        min: -2,
        max: 2,
        step: 0.1
      },
      presence_penalty: {
        name: '存在惩罚',
        desc: '增加新主题出现的概率',
        type: 'number',
        default: 0,
        min: -2,
        max: 2,
        step: 0.1
      },
      repetition_penalty: {
        name: '重复惩罚',
        desc: '降低重复词语的出现概率',
        type: 'number',
        default: 1,
        min: 0.1,
        max: 1.5,
        step: 0.1
      }
    },
    pricing: {
      inputPrice: 0.008,
      outputPrice: 0.024,
      currency: 'USD'
    },
    apiEndpoint: 'https://api.anthropic.com/v1/complete',
    documentationUrl: 'https://docs.anthropic.com/claude/docs'
  },
  {
    id: 'claude-instant-1',
    name: 'claude-instant-1',
    title: 'Claude Instant',
    alias: 'Claude Instant',
    desc: 'Anthropic的快速响应AI助手，适合简单任务',
    logo: 'https://www.anthropic.com/favicon.ico',
    vendor: 'Anthropic',
    releaseDate: '2023-03-14',
    version: '1.0',
    maxInputTokens: 100000,
    maxOutputTokens: 100000,
    capabilities: ['快速对话', '简单问答', '文本分类'],
    level: 1,
    params: {
      temperature: {
        name: '温度',
        desc: '控制输出的随机性',
        type: 'number',
        default: 0.7,
        min: 0,
        max: 1,
        step: 0.1
      },
      max_tokens: {
        name: '最大输出token数',
        desc: '控制生成文本的最大长度',
        type: 'number',
        default: 1024,
        min: 1,
        max: 1024,
        step: 1
      },
      top_p: {
        name: 'Top P',
        desc: '控制输出的多样性',
        type: 'number',
        default: 1,
        min: 0,
        max: 1,
        step: 0.1
      },
      top_k: {
        name: 'Top K',
        desc: '控制输出的多样性',
        type: 'number',
        default: 5,
        min: 1,
        max: 10,
        step: 1
      },
      frequency_penalty: {
        name: '频率惩罚',
        desc: '降低重复词语的出现概率',
        type: 'number',
        default: 0,
        min: -2,
        max: 2,
        step: 0.1
      },
      presence_penalty: {
        name: '存在惩罚',
        desc: '增加新主题出现的概率',
        type: 'number',
        default: 0,
        min: -2,
        max: 2,
        step: 0.1
      },
      repetition_penalty: {
        name: '重复惩罚',
        desc: '降低重复词语的出现概率',
        type: 'number',
        default: 1,
        min: 0.1,
        max: 1.5,
        step: 0.1
      }
    },
    pricing: {
      inputPrice: 0.0016,
      outputPrice: 0.0055,
      currency: 'USD'
    },
    apiEndpoint: 'https://api.anthropic.com/v1/complete',
    documentationUrl: 'https://docs.anthropic.com/claude/docs'
  },
  {
    id: 'gpt-4-32k',
    name: 'gpt-4-32k',
    title: 'GPT-4 32K',
    alias: 'GPT-4 长文本版',
    desc: 'GPT-4的扩展版本,支持更长的上下文',
    logo: 'https://openai.com/favicon.ico',
    vendor: 'OpenAI',
    releaseDate: '2023-06-13',
    version: '1.0',
    maxInputTokens: 32768,
    maxOutputTokens: 4096,
    capabilities: ['长文本处理', '复杂任务分析', '上下文理解'],
    level: 2,
    params: {
      temperature: {
        name: '温度',
        desc: '控制输出的随机性',
        type: 'number',
        default: 0.7,
        min: 0,
        max: 1,
        step: 0.1
      },
      max_tokens: {
        name: '最大输出token数',
        desc: '控制生成文本的最大长度',
        type: 'number',
        default: 1024,
        min: 1,
        max: 1024,
        step: 1
      },
      top_p: {
        name: 'Top P',
        desc: '控制输出的多样性',
        type: 'number',
        default: 1,
        min: 0,
        max: 1,
        step: 0.1
      },
      top_k: {
        name: 'Top K',
        desc: '控制输出的多样性',
        type: 'number',
        default: 5,
        min: 1,
        max: 10,
        step: 1
      },
      frequency_penalty: {
        name: '频率惩罚',
        desc: '降低重复词语的出现概率',
        type: 'number',
        default: 0,
        min: -2,
        max: 2,
        step: 0.1
      },
      presence_penalty: {
        name: '存在惩罚',
        desc: '增加新主题出现的概率',
        type: 'number',
        default: 0,
        min: -2,
        max: 2,
        step: 0.1
      },
      repetition_penalty: {
        name: '重复惩罚',
        desc: '降低重复词语的出现概率',
        type: 'number',
        default: 1,
        min: 0.1,
        max: 1.5,
        step: 0.1
      }
    },
    pricing: {
      inputPrice: 0.06,
      outputPrice: 0.12,
      currency: 'USD'
    },
    apiEndpoint: 'https://api.openai.com/v1/chat/completions',
    documentationUrl: 'https://platform.openai.com/docs/models/gpt-4-32k-context'
  },
  {
    id: 'currentApp',
    name: 'palm-2',
    title: 'PaLM 2',
    alias: 'Google PaLM 2',
    desc: 'Google的大型语言模型,擅长多语言任务和推理',
    logo: 'https://www.google.com/favicon.ico',
    vendor: 'Google',
    releaseDate: '2023-05-10',
    version: '1.0',
    maxInputTokens: 8192,
    maxOutputTokens: 1024,
    capabilities: ['多语言处理', '逻辑推理', '代码生成'],
    level: 2,
    params: {
      temperature: {
        name: '温度',
        desc: '控制输出的随机性',
        type: 'number',
        default: 0.7,
        min: 0,
        max: 1,
        step: 0.1
      },
      max_tokens: {
        name: '最大输出token数',
        desc: '控制生成文本的最大长度',
        type: 'number',
        default: 1024,
        min: 1,
        max: 1024,
        step: 1
      },
      top_p: {
        name: 'Top P',
        desc: '控制输出的多样性',
        type: 'number',
        default: 1,
        min: 0,
        max: 1,
        step: 0.1
      },
      top_k: {
        name: 'Top K',
        desc: '控制输出的多样性',
        type: 'number',
        default: 5,
        min: 1,
        max: 10,
        step: 1
      },
      frequency_penalty: {
        name: '频率惩罚',
        desc: '降低重复词语的出现概率',
        type: 'number',
        default: 0,
        min: -2,
        max: 2,
        step: 0.1
      },
      presence_penalty: {
        name: '存在惩罚',
        desc: '增加新主题出现的概率',
        type: 'number',
        default: 0,
        min: -2,
        max: 2,
        step: 0.1
      },
      repetition_penalty: {
        name: '重复惩罚',
        desc: '降低重复词语的出现概率',
        type: 'number',
        default: 1,
        min: 0.1,
        max: 1.5,
        step: 0.1
      }
    },
    pricing: {
      inputPrice: 0.005,
      outputPrice: 0.005,
      currency: 'USD'
    },
    apiEndpoint:
      'https://generativelanguage.googleapis.com/v1beta2/models/chat-bison-001:generateMessage',
    documentationUrl: 'https://developers.generativeai.google/products/palm'
  },
  {
    id: 'llama-2-70b',
    name: 'llama-2-70b',
    title: 'LLaMA 2 70B',
    alias: 'Meta LLaMA 2',
    desc: 'Meta的开源大型语言模型,性能强大且可自由使用',
    logo: 'https://www.llama.com/favicon.ico',
    vendor: 'Meta',
    releaseDate: '2023-07-18',
    version: '2.0',
    maxInputTokens: 4096,
    maxOutputTokens: 4096,
    capabilities: ['开放域对话', '文本生成', '知识问答'],
    level: 1,
    params: {
      temperature: {
        name: '温度',
        desc: '控制输出的随机性',
        type: 'number',
        default: 0.7,
        min: 0,
        max: 1,
        step: 0.1
      },
      max_tokens: {
        name: '最大输出token数',
        desc: '控制生成文本的最大长度',
        type: 'number',
        default: 1024,
        min: 1,
        max: 1024,
        step: 1
      },
      top_p: {
        name: 'Top P',
        desc: '控制输出的多样性',
        type: 'number',
        default: 1,
        min: 0,
        max: 1,
        step: 0.1
      },
      top_k: {
        name: 'Top K',
        desc: '控制输出的多样性',
        type: 'number',
        default: 5,
        min: 1,
        max: 10,
        step: 1
      },
      frequency_penalty: {
        name: '频率惩罚',
        desc: '降低重复词语的出现概率',
        type: 'number',
        default: 0,
        min: -2,
        max: 2,
        step: 0.1
      },
      presence_penalty: {
        name: '存在惩罚',
        desc: '增加新主题出现的概率',
        type: 'number',
        default: 0,
        min: -2,
        max: 2,
        step: 0.1
      },
      repetition_penalty: {
        name: '重复惩罚',
        desc: '降低重复词语的出现概率',
        type: 'number',
        default: 1,
        min: 0.1,
        max: 1.5,
        step: 0.1
      }
    },
    pricing: {
      inputPrice: 0,
      outputPrice: 0,
      currency: 'USD'
    },
    apiEndpoint: 'https://www.llama.com/',
    documentationUrl: 'https://www.llama.com/'
  }
  // 可以继续添加更多模型...
]

// 处理获取所有模型的请求
export const handlers = [
  http.get('/mock/llm-models', () => {
    return HttpResponse.json({
      code: 200,
      data: models,
      message: 'Success'
    })
  }),

  // 处理根据ID获取特定模型的请求
  http.get('/mock/llm-models/:id', ({ params }) => {
    const { id } = params
    const model = models.find((m) => m.id === id)
    if (model) {
      return HttpResponse.json({
        code: 200,
        data: model,
        message: 'Success'
      })
    } else {
      return new HttpResponse(null, { status: 404, statusText: '未找到模型' })
    }
  })
]

const appList = [
  {
    id: 1,
    name: 'app1',
    title: '应用1',
    desc: '这是第一个应用',
    logo: 'https://www.google.com/favicon.ico',
    chatConfig: {
      historyCount: 10, // 保留历史记录数
      maxToken: 4096, // 最大token数
    },
    modelConfig: {
      key: 'gpt-4-turbo',
      params: {
        temperature: 0.7,
        max_tokens: 1024,
        top_p: 1,
        top_k: 5,
        frequency_penalty: 0,
        presence_penalty: 0,
        repetition_penalty: 1
      }
    },
    knowledgeBases: [1, 2, 3], // 已关联的数据集
    files: [1, 2, 3], // 已关联的文件
    plugins: ['enableWebSearch'],
    createdAt: '2024-02-20 10:00:00',
    updatedAt: '2024-02-20 10:00:00'
  }
]
